package db

import (
	//"github.com/astaxie/beego"
	"database/sql"
	_ "github.com/mattn/go-sqlite3"
)

func Opendb(dbname string) *sql.DB {

      dbname = "./db/"+dbname +".db";
	  db, err :=  sql.Open("sqlite3", dbname)
	 

	  if(err!=nil){
		  return nil
	  }else{
		  return db
	  }
}




func Insert(dbname string , tablename string , data interface{}){

}

func Delete(dbname string,tablename string ,columname string ,columnvalue interface{}){

}


func Update(dbname string ,tablename string,columname string ,columnvalue interface{}){

}



/*
func Search(dbname string ,tablename string , searchcolums string ,condition string) interface{} {
	 //var res interface

	 db := opendb(dbname)
	 if(db == nil){
	  Pic("seach op","common db.go can not opend db")
	  return nil
	 }else{ 
		sqlstm := "select "+searchcolums+" from "+tablename+" where "+condition;
		
		//Pic("sqlstmt",sqlstm);

		rows, err := db.Query(sqlstm) 
		if(err!=nil){
			Pic("seach op","common db.go can db query fail")
			return nil
		}else{

			//Pic("seach op","common db.go can db query return rows")
			for rows.Next() {
				//Pic("seach for data","this is data")
				return rows;
			}
            return nil
		}
	 }
	

} 
 */